<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/resources/modular/plugin/taglibs.jsp" %>
<!doctype html>
<head content="-我的">
    <%@ include file="/resources/modular/head/inside_head.jsp" %>
</head>
<body class="GC_Menu_7" name="GC_indvidual">

<%@ include file="/resources/modular/plugin/mainMenu.jsp" %>

<div class="page" name="GC_individual_bandingbankcard">

    <%@ include file="/resources/modular/plugin/mainTopMenu.jsp" %>

    <%@ include file="/resources/modular/plugin/individualMeun.jsp" %>

    <div class="page_right">
        <div class="my_bindBankcard_dv">
            <c:if test="${empty card}">
                尚未绑定银行卡
            </c:if>
            <c:if test="${!empty card}">
                <p class="my_bindBankcard_dvp1">
                    <span>持卡人</span>
                    <span>${card.cardholder}</span>
                </p>
                <div class="my_bindBankcard_dvdv1">
                    <span>银行卡号</span>
                    <span>${card.bankcardnumber}</span>
                    <a class="my_bindBankcard_changebtn" href="javascript:;">更换</a>
                    <div class="my_bindBankcard_changedv">
                        <span>提现密码：</span>
                        <input type="password" placeholder="请输入提现密码">
                        <a class="my_bindBankcard_changedvbtn" href="javascript:;">确认</a>
                    </div>
                </div>


                <div class="my_bindBankcard_changecard">
                    <span>银行卡号</span>
                    <input type="text" id="GC_bankcard_number" placeholder="请输入银行卡号">
                    <span>
                    	<a class="my_bindBankcard_changecardbtn1" href="javascript:;">确认</a>
                        <a class="my_bindBankcard_changecardbtn2" href="javascript:;">取消</a>
                    </span>
                </div>
                <div class="my_bindBankcard_changecard">
                    <span>再次输入银行卡号</span>
                    <input type="text" placeholder="请再次输入银行卡号">
                    <span>
                    	<a class="my_bindBankcard_changecardbtn3" href="javascript:;">确认</a>
                        <a class="my_bindBankcard_changecardbtn4" href="javascript:;">取消</a>
                    </span>
                </div>
            </c:if>
        </div>
    </div>

</div>
</body>
</html>
<%@ include file="/resources/modular/foot/inside_footer.jsp" %>
<script type="text/javascript" src="${basePath}resources/js/v2/youyicloud-md5.js"></script>
<script type="text/javascript">
    var regbank=/^(\d{4}\s){4}\d{0,5}$/;
    <%-- 验证提现密码 --%>
    $(".my_bindBankcard_changedvbtn").on("click", function () {
        var my_bindBankcard_val = $(this).prev("input").val();
        if (typeof(my_bindBankcard_val) != "undefined" && my_bindBankcard_val.length > 0) {
            $.ajax({
                url: '${basePath}v2/individual/verifyTransferPassword',
                type: 'GET',
                data: {
                    "password": createPassword(my_bindBankcard_val, my_bindBankcard_val)
                },
                error: function (response) {
                    $errorMsg(response);
                },
                success: function (ret) {
                    if (ret.result) {
                        Frontend();
                    } else {
                        alert(ret.info);
                    }
                }
            });
        }
    });

    <%-- 更换银行卡号的点击按钮 --%>
    $(".my_bindBankcard_changecardbtn3").on("click", function () {
        changeBankCard();
    });

    <%-- 更换银行卡号 --%>
    function changeBankCard() {
        var my_bindBankcard_val = $("#GC_bankcard_number").val();

        var my_bindBankcard3=$(".my_bindBankcard_changecardbtn1").parent().prev("input").val();
        if(regbank.test(my_bindBankcard_val) && my_bindBankcard_val==my_bindBankcard3){
            var lastfour=my_bindBankcard2.substring((my_bindBankcard2.length-4), my_bindBankcard2.length);
            $(".my_bindBankcard_dvdv1 span:eq(1)").text("**** **** **** "+lastfour);
            $(".my_bindBankcard_dvdv1").stop().show();
            $(".my_bindBankcard_changedv, .my_bindBankcard_changecard").hide();
        }

        if (typeof(my_bindBankcard_val) != "undefined" && my_bindBankcard_val.length > 0) {
            $.ajax({
                url: '${basePath}v2/individual/editbankcard',
                type: 'POST',
                data: {
                    "cardid" : ${card.cardid},
                    "bankcardnumber": my_bindBankcard_val
                },
                error: function (response) {
                    $errorMsg(response);
                },
                success: function (ret) {
                    if (ret.result) {
                        alert(ret.info,"cur");
                    } else {
                        alert(ret.info);
                    }
                }
            });
        }
    }

    function Frontend() {
        $(".my_bindBankcard_changecard").stop().show();
        $(".my_bindBankcard_changedv").stop().hide();
        $(".my_bindBankcard_dvdv1").stop().hide();
        $(".my_bindBankcard_changebtn").text("更换");
    }

</script>